﻿#include "dlgmain.h"
#include "ui_dlgmain.h"
#include "keyboard/keyboard.h"
#include <QDesktopWidget>
#include <QDebug>
#include <QFileDialog>

int g_screenWidth = 0;
int g_screenHeight = 0;

DlgMain::DlgMain(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DlgMain)
{
    ui->setupUi(this);

    QDesktopWidget *deskWidget = QApplication::desktop();
    QRect screenrect = deskWidget->screenGeometry();
//    this->setFixedSize(screenrect.width(), screenrect.height());
    g_screenWidth = screenrect.width();
    g_screenHeight = screenrect.height();
//    m_homekeyboard = new HomeKeyboard(this);
//    m_homekeyboard->show();



    keyboard::Instance()->move((g_screenWidth - keyboard::Instance()->width())/2,
                               g_screenHeight - keyboard::Instance()->height());
    keyboard::Instance()->setVisible(false);
    ui->lineEdit_5->setInputMask("000.000.000.000");
}

DlgMain::~DlgMain()
{
    delete ui;
}

void DlgMain::on_pushButton_2_clicked()
{
//    QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
//                                                      "/home",
//                                                      QFileDialog::ShowDirsOnly
//                                                      | QFileDialog::DontResolveSymlinks);
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
                                                      "/home",
                                                      tr("Images (*.*)"));
    ui->lineEdit_4->setText(fileName);
}

void DlgMain::on_pushButton_3_clicked()
{
    int curIndex = ui->comboBox_2->currentIndex();
    qDebug() << curIndex << ui->comboBox_2->currentText();
    qDebug() << ui->lineEdit_5->text();
}
